#include<bits/stdc++.h>
using namespace std;

// const int N = 1e5+5, M = 1e5+5;
// int w[M], e[M], ne[M], h[N], idx;
// void add(int a, int b, int ww) {
//     w[idx] = ww; e[idx] = b; ne[idx] = h[a]; h[a] = idx ++ ;
// }

long long T,n,m,L,V,x;
#define N 100005
#define M 1000005
int l[N],r[N],idx,k[N],res;
//[l[i], r[i]] is over speed
long long p[M],c[M];
//p[i]= how many sxt in [1,i]
//c[i]= how many cars over speed at {i}
long long d,v,a;
struct sxt {
    int pos;
    int cpos; //c[pos]
    bool operator < (const sxt &T) {
        return cpos < T.cpos;
    }
} sxt[N];

int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin>>T;
    while(T--) {
        idx=1;
        memset(l,0,sizeof l);
        memset(r,0,sizeof r);
        memset(p,0,sizeof p);
        memset(c,0,sizeof c);
        memset(k,0,sizeof k);
        res=0;

        cin>>n>>m>>L>>V;

        for(int i=1;i<=n;i++){
            cin>>d>>v>>a;
            if(a>0){
                if(v>V){
                    l[idx]=d;
                    r[idx]=L;
                    idx++;
                }else{
                    int t=floor(1.0*(V*V-v*v)/(2*a));
                    l[idx]=min(L,d+t+1);
                    r[idx]=L;
                    idx++;
                }
            }else if(a<0){
                if(v>V){
                    int t=ceil(1.0*(V*V-v*v)/(2*a));
                    l[idx]=d;
                    r[idx]=min(L,d+t-1);
                    idx++;
                }
            }else{
                if(v>V){
                    l[idx]=d;
                    r[idx]=L;
                    idx++;
                }
            }
        }

        for(int i=1;i<=m;i++){
            cin>>x;
            p[x]=1;
            sxt[i]={x,0};
        }
        for(int i=1;i<=L;i++){
            p[i]+=p[i-1];
        }

        int cnt=0;
        for(int i=1;i<=idx;i++){
            int ll=l[i],rr=r[i];
            if(p[rr]-p[ll]>0){
                cnt++;
            }else{
                l[i]=0; r[i]=0;
            }
            c[ll]++; c[rr+1]--;
        }
        for(int i=1;i<=L;i++){
            c[i]+=c[i-1];
        }
        cout<<cnt<<" ";

        for(int i=1;i<=m;i++){
            sxt[i].cpos=c[sxt[i].pos];
        }
        sort(sxt+1, sxt+m+1);
        for(int i=1;i<=m;i++){
            if(sxt[i].cpos==0) continue;
            int t=sxt[i].pos;
            for(int j=1;j<=idx;j++){
                if(l[j]==0&&r[j]==0) continue;
                if(l[j]<=t&&t<=r[j]) {
                    k[j]++;
                }
            }
        }
        for(int i=1;i<=m;i++){
            if(sxt[i].cpos==0) continue;
            int t=sxt[i].pos;
            bool ff=0;
            for(int j=1;j<=idx;j++){
                if(l[j]==0&&r[j]==0) continue;
                if(l[j]<=t&&t<=r[j]&&k[j]==1) {
                    res++;
                    ff=1;
                    break;
                }
            }
            if(ff==0){
            for(int j=1;j<=idx;j++){
                if(l[j]==0&&r[j]==0) continue;
                if(l[j]<=t&&t<=r[j]) {
                    k[j]--;
                }
            }
            }
        }
        cout<<m-res<<"\n";
    }
    return 0;
}
